#!/bin/sh

# get the current path
CURPATH=`pwd`

chmod -R 777 data
chmod 777 notify


inotifywait -mr --timefmt '%d/%m/%y %H:%M' --format '%T %w %f' -e close_write /var/www/html/notify | while read date time dir file; do

    FILECHANGE=${dir}${file}
# convert absolute path to relative
    FILECHANGEREL=`echo "$FILECHANGE" | sed 's_'$CURPATH'/__'`

    php "/var/www/html/index.php" Notify

    echo -e "\n---------------------\nAt ${time} on ${date}, file $FILECHANGE was changed"
done
